# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=just
pkgver=1.2.0
pkgrel=0
pkgdesc="Just a command runner"
url="https://github.com/casey/just"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # limited by rust/cargo
license="CC0-1.0"
checkdepends="bash fzf"
makedepends="cargo"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/casey/just/archive/$pkgver/just-$pkgver.tar.gz
	minimize-size.patch
	"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen
}

check() {
	# Skipped tests are somehow broken.
	cargo test --frozen -- \
		--skip choose::default \
		--skip edit::editor_precedence \
		--skip choose::multiple_recipes \
		--skip functions::env_var_functions
}

package() {
	cargo install --locked --offline --path . --root="$pkgdir/usr"
	rm "$pkgdir"/usr/.crates*

	install -D -m 644 completions/just.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -D -m 644 completions/just.fish \
		"$pkgdir"/usr/share/fish/completions/$pkgname.fish
	install -D -m 644 completions/just.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
d70fe915da59c2c3baa11f861f5f8b21ad3a68112bfb010d99291347ba2e2e6663d0e0ec4299a894d2cb5bdc2e37d314e8e72936b2289e4ee0f327728ca6c656  just-1.2.0.tar.gz
413f4c196e88d1d33cd6bc01a5ed920f6f5cde3c71c5c9117541fd40536ed0f90e4b7baf20670e548dfcd9705c608b591294915d7632343d0b3f9fdb33d3e098  minimize-size.patch
"
